package Demo08.Demo0824;

import java.util.Scanner;

public class HomeWork {
    public static void main(String[] args) {
        //青蛙跳台阶问题
        /*   Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println(guaguagua(a));
        sc.close();*/
        //  写一个递归方法，输入一个非负整数，返回组成它的数字之和
       /* Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println(returnSum2(a));*/
        //递归求 N 的阶乘
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println(multiplication(a));
        sc.close();
    }

    public static int multiplication(int a){
        if(a == 1){
            return 1;
        }
        return a * multiplication(a-1);
    }
    public static int returnSum(int a){
        if(a < 10){
            return a;
        }
        return a % 10 + returnSum(a/10);
    } //写一个递归方法，输入一个非负整数，返回组成它的数字之和--方法一
    public static int returnSum2(int a){
        if(a > 10){
            return a % 10 + returnSum(a/10);
        }
        return a;
    }//写一个递归方法，输入一个非负整数，返回组成它的数字之和--方法二
    public static long guaguagua(int a){//设置成long类型是想着能够多填
        if(a == 1){
            return 1;
        }
        if(a == 2){
            return 2;
        }
        //从第三项开始进行关系式对待
        long key1 = 1;
        long key2 = 2;
        long res =  0;//用来接收前两项相加的和
        for (int i = 3; i <= a; i++) {
            res = key1 + key2;
            key1 = key2;
            key2 = res;
        }
        return res;
    } //  //青蛙跳台阶问题


}
